<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class ProjectInsertRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * 新增项目的表单验证
     *
     * @return array
     */
    public function rules()
    {
//        return array();

        return [
            //
            'subject'        => 'required',
            'invest_way'     => 'sometimes',
            'uid'            => 'sometimes|integer',
            'zone_id'        => 'sometimes|integer',
            'categories'     => 'required|array|max:3',
            'photo'          => 'sometimes',
            'ip'             => 'sometimes|ip',
            'invest_fund'    => 'sometimes|integer',
            'invest_value'   => 'sometimes|integer',
            'transfer_share' => 'sometimes|integer',
            'email'          => 'sometimes|email',
            'star'           => 'required',
            'bp_fileprize'   => 'sometimes|numeric',
            'fengkong'       => 'sometimes|numeric|max:5|min:1',
            'canyudu'        => 'sometimes|numeric|max:5|min:1',
            'huoyudu'        => 'sometimes|numeric|max:5|min:1',
            'caizheng'       => 'sometimes|numeric|max:5|min:1',
            'cycle'          => 'sometimes|integer',

        ];
    }

    public function attributes()
    {
        $attributes = array(

            'subject'        => '项目名称',
            'uid'            => '项目所属用户',
            'zone_id'        => '项目所在地',
            'categories'     => '行业分类',
            'photo'          => '列表页缩略图',
            'ip'             => '用户IP地址',
            'invest_fund'    => '融资金额',
            'invest_value'   => '投资前估值',
            'transfer_share' => '出让股份',
            'email'          => '用户Email',
            'invest_way'     => '融资方式',
            'star'           => '是否明星项目',
            'bp_fileprize'   => '商业计划书价格',
            'fengkong'       => '项目风控措施',
            'canyudu'        => '项目做市商参与度',
            'huoyudu'        => '项目做市商活跃度',
            'caizheng'       => '项目财务状况',

        );

//        return array();
        return $attributes;
    }

    public function messages()
    {
        $messages = [
            'required'       => ':attribute为必填选项',
            'integer'        => ':attribute必须为数字',
            'url'            => ':attribute必须为合乎规范的url地址',
            'email'          => ':attribute必须为合乎规范的邮箱地址',
            'ip'             => ':attribute必须为合乎规范的ip地址',
            'categories.max' => ':attribute不能超过三个行业',
            'caizheng.max'   => ':attribute不能超过:max',
            'caizheng.min'   => ':attribute不能小于:min',
            'huoyudu.max'    => ':attribute不能超过:max',
            'huoyudu.min'    => ':attribute不能小于:min',
            'canyudu.max'    => ':attribute不能超过:max',
            'canyudu.min'    => ':attribute不能小于:min',
            'fengkong.max'   => ':attribute不能超过:max',
            'fengkong.min'   => ':attribute不能小于:min',
        ];

        return $messages;
    }
}
